﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApp2
{
    class MainContext : ApplicationContext
    {
        public static bool isLogin = false;

        public MainContext()
        {
            Login();
        }

        private void OnLoginSuccess()
        {
            UIManager.LoadWindow(FormFactory.GetForm(FormType.Main));
        }

        private void Login()
        {
            var form = FormFactory.GetForm(FormType.Login);
            form.FormClosed += (a, b) =>
            {
                if (isLogin)
                {
                    OnLoginSuccess();
                }
                else
                {
                    Application.Exit();
                }
            };
            UIManager.LoadWindow(form);
        }
    }
}
